// Upgrade NOTE: commented out 'float4x4 _Object2World', a built-in variable
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'


Shader  "Handle/TotemFogged" {

	Properties
	 {
 _MainTex ("_MainTex", 2D) = "white" {}
 _Blend ("Blend Amount", Float) = 0
 _BlendColour ("Blend Colour", Color) = (0.5,0.5,0.5,0)
 _Plane ("_Plane", Vector) = (0,1,0,1)
 _FogColour ("fog colour", Color) = (1,1,1,1)
 _Density ("Fog Density", Float) = 0.1
}

	

	SubShader
     {
  Tags { "LIGHTMODE"="ForwardBase" "QUEUE"="Geometry" "RenderType"="Opaque" }

    LOD 100
	Pass
	{
	
	

	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#include "UnityCG.cginc"
    //#define Fixed3(value)  fixed3(value, value,value)

	struct VertexInput {
    fixed4 vertex : POSITION;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed4 tangent : TANGENT;
    fixed3 normal : NORMAL;
    fixed4 xlv_COLOR0 : COLOR;
	//VertexInput
	};


	struct VertexOutput {
	fixed4 pos : SV_POSITION;
    UNITY_FOG_COORDS(1)
    //fixed3 xlv_COLOR0 : COLOR;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed3 xlv_TEXCOORD4 : TEXCOORD4;
	//VertexOutput
	};

	

 
 
 
 // float4x4 _Object2World;
 float4 _MainTex_ST;
 float _Density;
 float4 _Plane;



	

 sampler2D _MainTex;
 float _Blend;
 float4 _BlendColour;
 float4 _FogColour;





	VertexOutput vert (VertexInput v)
	{
	VertexOutput o;
	//o.pos = UnityObjectToClipPos (v.vertex);
	//o.xlv_TEXCOORD0 = TRANSFORM_TEX(v.xlv_TEXCOORD0, _MainTex);
	
  float2 tmpvar_1=float2(0,0);
  float3 tmpvar_2 = float3(0,0, 0);
  o.pos = UnityObjectToClipPos( v.vertex);
  o.xlv_TEXCOORD0 = ((v.xlv_TEXCOORD0 * _MainTex_ST.xy) + _MainTex_ST.zw);
  o.xlv_TEXCOORD1 = tmpvar_1;
  o.xlv_TEXCOORD2 = tmpvar_2;
  o.xlv_TEXCOORD3 = ((dot (
    mul(unity_ObjectToWorld , v.vertex)
  .xyz, _Plane.xyz) - _Plane.w) * _Density);


    UNITY_TRANSFER_FOG(o,o.vertex);
   
	return o;
	}


	fixed4 frag(VertexOutput i) : SV_Target
    {
    //fixed4 tmpvar_2 = tex2D(_MainTex, i.uv);
	
  float4 tex_1;
  float4 main_color_2;
  main_color_2.w = 0.0;
  fixed4 tmpvar_3;
  tmpvar_3 = tex2D (_MainTex, i.xlv_TEXCOORD0);
	UNITY_APPLY_FOG(i.fogCoord, tmpvar_3);
  tex_1 = tmpvar_3;
  main_color_2.xyz = (tex_1.xyz + ((_BlendColour.xyz * _Blend) * tex_1.w));
  main_color_2.xyz = lerp (main_color_2.xyz, _FogColour.xyz, fixed3(clamp (clamp (i.xlv_TEXCOORD3, 0.0, 1.0), 0.0, 1.0)));
  return main_color_2;

	}
	ENDCG
	}
  }
}

